package Lambda.Consumer;


import java.util.function.Consumer;

//Consumer：是消费一个数据
public class Consumerdemo2 {

    /*jdk源码：
    public interface Consumer<T> {//Consumer<T>参数是泛型,返回值是空的
        void accept(T t);*/
    //两个消费者一起消费一个
   private static void method(String name,Consumer<String> con1 ,Consumer<String> con2){
       con1.accept(name);
       con2.accept(name);
       //con1.andThen(con2).accept(name);//con1先消费,然后con2再消费name;
   }

    public static void main(String[] args) {
        method("Hello",
                (name)->{
                    //将数据全部转换为大写
                    System.out.println(name.toUpperCase());
                },
                (name)->{
                    //将数据全部转换为小写
                    System.out.println(name.toLowerCase());
                });
    }
}
